import request from '@/utils/request'
import * as proxy from '@/constants/proxy'
import { ObjectType, Pagination } from 'typings/interfaces'

/* 获取用户列表分页（选择用户控件） */
export function getUsersByPage(pagination: Omit<Pagination, 'total'>, params: ObjectType) {
  return request({
    url: proxy.CHECC_API_CMS + '/user',
    method: 'get',
    params: {
      ...params,
      current: pagination.pageNum,
    },
  })
}

export const getUsers = params => request({
  url: proxy.CHECC_API_PROCESS + '/user',
  method: 'get',
  params: {
    size: 500,
  }
})
export const fetchRecordsRequest = (pagination: ObjectType, params: ObjectType) =>
  request({
    url: proxy.CHECC_API_CMS + '/user/getUsersList',
    method: 'get',
    params: {
      ...params,
      current: pagination.pageNum,
      size: pagination.pageSize,
      orderBy: pagination.orderBy,
      orderType: pagination.orderType,
    },
  })

// 获取全部用户，无分页，无条件筛选
export const fetchGetAllUser = () =>
  request({
    url: proxy.CHECC_API_CMS + '/user/getAll',
    method: 'get',
  })

export const editRecordRequest = (data: ObjectType) =>
  request({
    url: proxy.CHECC_API_CMS + '/user/update',
    method: 'post',
    data,
  })
